
#ifndef _GL_SKELETONFRAME_H_
#define _GL_SKELETONFRAME_H_

#include "openglframe.h"
#include "meshdef/gskeleton.h"
#include "skelanim/motion.h"
#include "skelanim/animator.h"
#include "glDrawFunctions.h"

/// An specialized openGLFrame for rendering skeletons
class GLSkeletonFrame: public OpenGLFrame {
   Q_OBJECT
public:
   GLSkeletonFrame(QWidget* parent=0, const QGLWidget* shareWidget = 0, Qt::WFlags f=0);
   ~GLSkeletonFrame();
   
   bool loadSkeleton(const QString&);
   bool loadMotion(const QString&);
   
   GSkeleton* getSkeleton() { return skeleton; }
   Motion* getMotion() { return motion; }
   Animator* getAnimator() { return animator; }
   
   int nMaxofFrames() {
      if (skeleton==0 or motion==0 or animator==0) return 0;
      else return motion->getMotionSize();
   }
   
protected:
   void paintGL();
   virtual void mousePressEvent(QMouseEvent *);
   void keyPressEvent(QKeyEvent *);
   void focusInEvent(QFocusEvent *);
   void focusOutEvent(QFocusEvent *);
   
private:
   GSkeleton                *skeleton;   // the skeleton
   Motion                   *motion;   //
   Animator                 *animator;
   
public slots:
   void animateFrame(int);
};

#endif
